// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.1
import "storage.js" as Store
Page {
    id:settings
    tools: bakuptool
    width: parent.width
    height: parent.height

    property Item colorSelectionDialogItem:colorDialog
     orientationLock: appWindow.lockposition
    property bool atbegin: true

    Rectangle {
        id: header
        anchors.top: parent.top
        width: parent.width
        height: 70
        color: "dodgerblue"
        Label {
            anchors.centerIn: parent
            font.bold: true
            font.pixelSize: 35
            color: "White"
            text: "设置"
        }
    }
    Flickable{
        clip: true
        id:flickbale1
        width:parent.width

        height: parent.height-80
        anchors.top:header.bottom
        anchors.bottom: parent.bottom
        contentHeight: mainitem.height
        contentWidth: parent.width-5
        flickableDirection:Flickable.VerticalFlick
        pressDelay: 200


     Column{
         id:mainitem
         height: children.height
         spacing: 10
         width:parent.width

      Row{

          Rectangle {
               width: parent.width
               height: 10
               opacity: 0.001
           }

    }


    Row{
        id :chosedark
        width:parent.width
        height: 60



        ButtonRow{
            checkedButton:appWindow.platformStyle === defaultStyle?buttondefault:
                          (appWindow.platformStyle===customStyle? buttondeep: buttonlight)
           Button{
            id:buttonlight
             width:150


             text: "默认"
              onClicked: { theme.inverted = false
               appWindow.platformStyle=defqiubai
              Store.callbackFunction("platformStyle","defqiubai")
              Store.callbackFunction("theme.inverted",false);
              }

           }
           Button{
                id:buttondeep
               width:150
               text: "深色"

               onClicked: { theme.inverted = true;
                   appWindow.platformStyle =customStyle;
                   Store.callbackFunction("platformStyle","customStyle");
                   Store.callbackFunction("theme.inverted",true);
                  }
           }
           Button{
                id:buttondefault
               width:150
               text: "浅色"

               onClicked: {
                   theme.inverted = false
                   appWindow.platformStyle =defaultStyle;
                   Store.callbackFunction("theme.inverted",false);
                   Store.callbackFunction("platformStyle","defaultStyle");
                  }
           }
        }
//           Button{
//               width:150
//               text: "defaultStyle"
//               anchors.left: buttondeep.right
//               anchors.leftMargin: 10
//               onClicked: { theme.inverted = true;
//                   appWindow.platformStyle =defaultStyle
//                   Store.callbackFunction("platformStyle",defaultStyle);
//               }
//           }

       }
    Row{
        id:item1
        width:parent.width
        height: 60
        transformOrigin: Item.Center
        //anchors.verticalCenter: parent.verticalCenter

          Label{
              id:lable1

              text:"字体大小"
          }
          Slider {
              id: slider1
              width: parent.width-lable1.width-10

               minimumValue:15
              stepSize: 1
              value:appWindow.fontsize
              valueIndicatorVisible: true
              valueIndicatorText: appWindow.fontsize
              maximumValue: 30
              onValueChanged: {
                  if(slider1.pressed===true)
                    Store.callbackFunction("fontsize",slider1.value);
              }
          }
       }

    Row{
         id:item2
         width:parent.width
         transformOrigin: Item.Center
         height: 60

           Label{
               id:item2lable11

               text:"颜色"
           }
           Slider {
               id: slider11
               width: 400

               stepSize: 1
               maximumValue: 19
               onValueChanged: {
                     if(slider11.pressed===true){
                   //Store.callbackFunction("theme.colorScheme",slider11.value);
                   theme.colorScheme = slider11.value}
               }
           }
        }

     Row {
     id : item3
        height: button3.height
        transformOrigin: Item.Center
     Label {
         id :label1

         text:"选择内容颜色: "
     }
     TextEdit {

         id:text1
         enabled: false

         font.pointSize:appWindow.fontsize

         color: Store.getContentColor()
         text:"糗事的颜色"

       }

     Button{
         id :button3
         width:80
         text:"选择"

         onClicked: {
                                colorDialog.titleText = ("选择糗事颜色")
                                colorDialog.useName2 = false
                               // colorSelectionDialog.selectItem = text1
                                colorDialog.showColor = true
                                colorDialog.showBackPic = false
                                colorDialog.showBookIcon = false
                                colorDialog.which = "contentcolor"
                                colorDialog.open()
                            }
     }
}

     Row {
     id : item4
    height: button43.height
     Label {
         id :label41

         text:"选择标签颜色: "
     }
     Text {

         id:text41
         enabled: false
         width: 150
         font.pointSize: 18

         color: Store.getlabelcolor()
         text:"标签的颜色"

       }

     Button{
         id :button43
         width:80
         text:"选择"

         onClicked: {
                                colorDialog.titleText = ("选择标签颜色")
                                colorDialog.useName2 = false
                               // colorSelectionDialog.selectItem = text1
                                colorDialog.showColor = true
                                colorDialog.showBackPic = false
                                colorDialog.showBookIcon = false
                                colorDialog.which = "labelcolor"
                                colorDialog.open()
                            }
     }
}


     Row {
     id : item14
     visible: false

     Label {
         id :label141

         text:"选择程序颜色: "
     }
     Text {

         id:text141
         enabled: false
         width: 150
         font.pointSize: 18

         color: Store.getlabelcolor()
         text:"程序颜色"

       }

     Button{
         id :button143
         width:80
         text:"选择"

         onClicked: {
                                colorDialog.titleText = ("选择程序颜色")
                                colorDialog.useName2 = (false)
                               // colorSelectionDialog.selectItem = text1
                                colorDialog.showColor = true
                                colorDialog.showBackPic = false
                                colorDialog.showBookIcon = false
                                colorDialog.which = "systemcolor"
                                colorDialog.open()
                            }
     }
}



    Row{
        id:item5


      ButtonRow{
       checkedButton: appWindow.showimage?button54:button53
        Button{

            id :button53
            width:80
            text:"不看图！"

            onClicked: {
               // button53.style = NegativeButtonStyle
               // button54.style =PositiveButtonStyle
                Store.callbackFunction("showimage","false")
            }
        }
        Button{
            id :button54
            width:80
            text:"要真相"

            onClicked: {
                //button54.style = NegativeButtonStyle
                //button53.style =PositiveButtonStyle
                Store.callbackFunction("showimage","true")
            }
        }
}
  }
    Row{
      id:item6

       ButtonRow{
           checkedButton: appWindow.showStatusBar?button64:button63
       Button{
           id :button63
           width:150


           text: " 隐藏状态栏"
           onClicked:{
               appWindow.showStatusBar =false
                 Store.setSetting("showStatusBar",false)}
       }
       Button{
           id :button64
           width:150


           text: "显示状态栏";
           onClicked: {appWindow.showStatusBar =true
               Store.setSetting("showStatusBar",true)

           }
       }

       }
  }

    Row{
      id:item7

       ButtonRow{

       Button{
           id :button73
           width:150

           checked: appWindow.lockposition===PageOrientation.LockLandscape
           text: "横屏"
           onClicked:{
               //appWindow.showStatusBar =false
               Store.setSetting("lockposition",PageOrientation.LockLandscape )}
       }
       Button{
           id :button74
           width:150

           checked: appWindow.lockposition===PageOrientation.LockPortrait
           text: "竖屏";
           onClicked: {//appWindow.showStatusBar =true
               Store.setSetting("lockposition",PageOrientation.LockPortrait)

           }
       }
       Button{
           id :button75
           width:150
            checked: appWindow.lockposition===PageOrientation.Automatic

           text: "自动";
           onClicked: {//appWindow.showStatusBar =true
               Store.setSetting("lockposition",PageOrientation.Automatic)

           }
       }
       }
  }



     function test(){
         Store.initialize();
         text1.text = Store.getSetting("contentcolor");

        // console.log("--------------"+Store.getSetting("contentcolor"));
     }

}

  }
SelectColor{
        id:colorDialog
}
    ToolBarLayout {
          id: bakuptool
          visible: true
          ToolIcon {
              platformIconId: "toolbar-back"

              onClicked:  appWindow.pageStack.pop();
          }
      }
}
